def consumer():
    r = 'AA'
    while True:
        n = yield r
        print('consuming %s ...' % n)
        if not n:
            return
        r = '200 ok'


def produce(c):
    r = c.send(None)
    n = 0
    while n < 5:
        n = n + 1
        print('producing n:%s, r:%s...' % (n,r))
        r = c.send(n)
        print(' consumer return: %s' % r)
    c.close()


c = consumer()
produce(c)
